package com.neu.controller;

import com.neu.service.CartService;
import com.neu.utils.ResultModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/cart")
public class CartController {

    @Autowired
    CartService cartService;

    @PutMapping("/{customerId}/plus")
    public ResultModel plus(@PathVariable("customerId")Integer customerId,Integer shopId,Integer foodId){
        ResultModel resultModel = new ResultModel();
        String sign = cartService.plus(customerId,shopId,foodId);
        resultModel.setData(sign);
        resultModel.setMsg("商品添加成功！");
        return resultModel;
    }

    @PutMapping("/{customerId}/minus")
    public ResultModel minus(@PathVariable("customerId")Integer customerId,Integer shopId,Integer foodId){
        ResultModel resultModel = new ResultModel();
        String sign = cartService.minus(customerId,shopId,foodId);
        resultModel.setData(sign);
        resultModel.setMsg("商品减少成功!");
        return resultModel;
    }

}
